<template>
   <div class="goods-list">
      <div class="goods-item" v-for="item in goodsList" @click="handlerClick(item.proid)">
         <img :src="item.img1" alt="">
         <p class="name">{{ item.proname }}</p>
         <p class="price">￥{{ item.originprice }}</p>
      </div>

   </div>
</template>
<script setup lang="ts">
import { useRouter } from 'vue-router'

type GoodsType = {
   proid: string,
   img1: string,
   proname: string,
   originprice: string,
   [propName: string]: any
}

const props = defineProps<{ goodsList: GoodsType[] }>()

const router = useRouter()
const handlerClick = (id) => {
  router.push(`/detail/${id}`)
}

</script>
<style scoped lang="scss">
.goods-list {
   margin: 10px;
   .goods-item {
      width: 50%;
      box-sizing: border-box;
      padding: 5px;
      float: left;
      text-align: center;
      font-size: 0.8em;

      img {
         width: 80%;
         height: 150px;
         margin-left: 15px;
      }
      .name {
         color: #333;
         height: 3em;
         line-height: 1.5em;

         border-radius: 5px solid red;
         -webkit-line-clamp: 2; // 两行省略号
         display: -webkit-box;
         -webkit-box-orient: vertical;
         overflow: hidden;
         text-overflow: ellipsis;
      }

      // .name {
      //    // 单行省略号
      //    color: #333;
      //    height: 3em;
      //    line-height: 1.5em;
      //    overflow: hidden;
      //    border: 1px solid red;
      //    text-overflow: ellipsis;
      //    white-space: nowrap;
      // }
      .price {
            color: red;
            font-weight: 900;
            }
      }
   }
</style>